<?php

include("connect.php");


function insertNewPublicationPerson($personid, $publicationid, $dblink) {

	$query = sprintf("INSERT INTO PublicationPerson (`PersonID`, `PublicationID`, `AddedOn`) VALUES (%s, %s, '%s')", mysql_real_escape_string($personid),
					mysql_real_escape_string($publicationid), gmdate("Y-m-j H:i:s", time() + 3600*12));

 

$result = mysql_query($query, $dblink);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    echo $message;
}

return  mysql_insert_id();



}


$personid = insertNewPublicationPerson($_POST["personid"], $_POST["publicationid"], $link);

echo $personid; 

mysql_close($link);
?>